<{include file='../include/header.html'}>

<div class="layui-fluid">
	<div class="layui-card">
		<div class="layui-card-body">
			<form class="layui-form layui-form-pane" action="">
				<div class="layui-form-item">
					<label class="layui-form-label">站点logo</label>
					<label class="layui-form-label" style="width:auto"><{URL}></label>
					<div class="layui-input-inline">
						<input type="text" id="logo" name="logo" value="<{C('site_logo')}>" required lay-verify="required" placeholder="请输入站点logo图片路径" autocomplete="off" class="layui-input">
					</div>
					<button type="button" class="layui-btn" id="upload"><i class="layui-icon">&#xe67c;</i> 上传</button>
					<button type="button" class="layui-btn layui-btn-primary" id="show">预览</button>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">站点名称</label>
					<div class="layui-input-block">
						<input type="text" name="name" value="<{C('site_name')}>" required lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">标题小尾巴</label>
					<div class="layui-input-block">
						<input type="text" name="name" value="<{C('title_end_content')}>" required lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter="submit">立即提交</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>

<script>
layui.use(['upload','form'], function(){
	var upload = layui.upload,
		form = layui.form;
	
	var uploadLogo = upload.render({
		elem: '#upload'
		,url: '<{url('index','upload_ajax','logo')}>'
		,done: function(data){
			if(data.status) {
				$('#logo').val(data.path);
				layer.alert('上传成功，图片路径已自动填入文本框',{icon:6});
			} else {
				layer.alert(data.msg,{icon:5});
			}
		}
		,error: function(){
			layer.alert('上传失败！',{icon:5});
		}
		,exts: 'gif|png|jpg|jpeg|webp'
		,size: 1024
	});
	
	$('#show').click(function() {
		var path = $('#logo').val();
		layer.alert('<img src="<{URL}>'+path+'" style="width:250px">',{title:'预览'});
	});
	
	form.on('submit(submit)',function(data) {
		$.post('<{url('config','site_ajax')}>',data.field,function(data) {
			if(data.status) {
				layer.alert(data.msg,{icon:6});
				location.reload();
			} else {
				layer.alert(data.msg,{icon:5});
			}
		});
		return false;
	});
});
</script>

<{include file='../include/footer.html'}>